import { defineStore } from 'pinia'
import { ref } from 'vue'
import { getEntityTemplate } from '@/utils/ejsTemplate.js'


export const useTemplateStore = defineStore('template', () => {
  const template = ref({
    Entity: getEntityTemplate('Entity'),
    Mapper: getEntityTemplate('Mapper'),
    Controller: getEntityTemplate('Controller'),
    Service: getEntityTemplate('Service'),
    Impl: getEntityTemplate('Impl'),
    Xml: getEntityTemplate('Xml'),
    ApiJs: getEntityTemplate('ApiJs'),
    IndexVue: getEntityTemplate( 'IndexVue'),
    IndexVue3: getEntityTemplate( 'IndexVue3'),
    FormVue: getEntityTemplate('FormVue'),
    FormVue3: getEntityTemplate('FormVue3'),
    Result: getEntityTemplate('Result'),
    SearchButtons: getEntityTemplate('SearchButtons'),
    MockJs: getEntityTemplate('MockJs')
  })
  const refreshTemplate = (type, newVal) => {
    template.value[type] = newVal
  }
  return {
    template,
    refreshTemplate,
  }
}, {
  persist: true
})
